import { mobxState } from "@/data";
import { toJS } from "mobx";

/**
 * @description 校验按钮权限 决定是否显示按钮
 * @param {Array} curPermissionIdent 参数一：权限标识列表
 * 
 */
const authButton = (curPermissionIdent = String) => {
    let allPermissions = toJS(mobxState.permissionList);
    // 类型安全校验
    if (!Array.isArray(allPermissions)) {
        return false;
    }

    // 空值处理
    if (!curPermissionIdent) {
        return false;
    }

    // 精确匹配判断
    return allPermissions.some(permission =>
        permission === curPermissionIdent
    );
}
export default authButton;